import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import themes from './theme.js'
const store = new Vuex.Store({
  state: {
    currentTheme: "defaultTheme",
    themes: themes
  },
  getters: {
    theme(state) {
      return state.themes[state.currentTheme].style
    },
	currentTheme: state => state.currentTheme  
  },
  mutations: {
    changeTheme(state, themeName = "defaultTheme") {
      state.currentTheme = themeName
	  // 保存当前主题到本地存储
	  uni.setStorageSync('currentTheme', themeName);  
    }
  }
})

export default store
